package com.youku
{
   import com.youku.interfaces.IRootData;
   import com.youku.data.RootData;
   import com.youku.constants.RootConstant;
   import com.youku.utils.StringUtil;
   
   public class RootDataParser extends Object
   {
      
      public function RootDataParser() {
         super();
      }
      
      public static function parseData(param1:Object) : IRootData {
         var _loc3_:String = null;
         var _loc2_:RootData = new RootData();
         _loc2_.videoId = param1["VideoIDS"];
         _loc2_.isRedirect = Number(param1["isRedirect"]);
         if(param1["passwordstr"])
         {
            _loc2_.passwords = unescape(param1["passwordstr"]);
         }
         _loc2_.winType = param1["winType"];
         if(_loc2_.winType == "index")
         {
            _loc2_.source = "index";
         }
         else if(_loc2_.winType == "interior" || _loc2_.winType == "adshow")
         {
            _loc2_.source = "video";
         }
         else
         {
            _loc2_.source = "out";
         }
         
         if(_loc2_.winType == "exterior" || _loc2_.winType == "index" || _loc2_.winType == "adshow" || _loc2_.winType == "interior" || _loc2_.winType == "popup" || _loc2_.winType == "touch")
         {
            _loc2_.winType = _loc2_.winType;
         }
         else
         {
            _loc2_.winType = "exterior";
         }
         if((PlayerConfig.partnerData) && PlayerConfig.partnerData.status == 1)
         {
            _loc2_.winType = "BDskin";
         }
         if(_loc2_.winType == "interior" || _loc2_.winType == "exterior" || _loc2_.winType == "popup" || _loc2_.winType == "BDskin" || _loc2_.winType == "touch")
         {
            _loc2_.isShowRelativeVideo = true;
         }
         else
         {
            _loc2_.isShowRelativeVideo = false;
         }
         if(param1["isShowRelatedVideo"])
         {
            if(String(param1["isShowRelatedVideo"]).toLowerCase() == "false")
            {
               _loc2_.isShowRelativeVideo = false;
            }
         }
         if(param1["partnerid"])
         {
            _loc2_.partnerId = param1["partnerid"];
         }
         if(param1["embedid"])
         {
            _loc2_.embedId = param1["embedid"];
         }
         if(param1["extstring"])
         {
            _loc2_.extstring = param1["extstring"];
         }
         _loc2_.type = param1["Type"];
         _loc2_.fid = param1["Fid"];
         _loc2_.pt = param1["Pt"];
         _loc2_.ob = param1["Ob"];
         _loc2_.pf = param1["Pf"];
         _loc2_.skinURL = param1["skin_url"];
         _loc2_.pluginXMLURL = param1["plugin_xml_url"];
         if(param1["firsttime"] != null)
         {
            _loc2_.firstTime = int(param1["firsttime"]);
         }
         if(param1["adext"] != null)
         {
            _loc2_.adext = param1["adext"];
         }
         if(param1["quality"])
         {
            _loc3_ = param1["quality"];
            if(!(_loc3_ == "low") && !(_loc3_ == "mid") && !(_loc3_ == "high") && !(_loc3_ == "1080p") && !(_loc3_ == "auto"))
            {
               _loc3_ = "auto";
            }
            _loc2_.firstQuality = _loc3_;
         }
         if(param1["isAutoPlay"] != null)
         {
            if(String(param1["isAutoPlay"]).toLowerCase() == "true")
            {
               _loc2_.autoPlay = true;
            }
            else
            {
               _loc2_.autoPlay = false;
            }
         }
         _loc2_.autoHide = RootConstant.CONTROLBAR_MODE_NORMAL;
         if(param1["autohide"])
         {
            _loc2_.autoHide = int(param1["autohide"]);
            if(_loc2_.autoHide < 0 || _loc2_.autoHide > 3)
            {
               _loc2_.autoHide = 0;
            }
         }
         if(param1["p"])
         {
            if(param1["p"] == "1")
            {
               _loc2_.autoPlay = true;
            }
         }
         if(param1["isLoop"])
         {
            _loc2_.isLoop = false;
            if(String(param1["isLoop"]).toLowerCase() == "true")
            {
               _loc2_.isLoop = true;
            }
         }
         if(param1["isMute"])
         {
            _loc2_.isMute = false;
            if(String(param1["isMute"]).toLowerCase() == "true")
            {
               _loc2_.isMute = true;
            }
         }
         if(param1["trialJS"])
         {
            _loc2_.trialJS = false;
            if(String(param1["trialJS"]).toLowerCase() == "true")
            {
               _loc2_.trialJS = true;
            }
         }
         _loc2_.THX = "off";
         _loc2_.showTHX = false;
         if(param1["THX"] != null)
         {
            _loc2_.showTHX = true;
            if(param1["THX"] == "on")
            {
               _loc2_.THX = "on";
            }
            else if(param1["THX"] == "off")
            {
               _loc2_.THX = "off";
            }
            else
            {
               _loc2_.showTHX = false;
            }
            
         }
         else
         {
            _loc2_.showTHX = false;
         }
         _loc2_.light = "on";
         if(param1["Light"] != null)
         {
            if(param1["Light"] == "on")
            {
               _loc2_.light = "on";
            }
            else
            {
               _loc2_.light = "off";
            }
         }
         _loc2_.showSideBar = true;
         if(param1["show_ce"] != null)
         {
            if(param1["show_ce"] == "0")
            {
               _loc2_.showSideBar = false;
            }
         }
         _loc2_.showSearch = true;
         if(param1["showsearch"] != null)
         {
            if(param1["showsearch"] == "0")
            {
               _loc2_.showSearch = false;
            }
         }
         _loc2_.showLoop = false;
         if(param1["showloop"] != null)
         {
            if(String(param1["showloop"]).toLowerCase() == "true")
            {
               _loc2_.showLoop = true;
            }
         }
         _loc2_.isUseStageVideo = false;
         if(param1["sv"] != null)
         {
            if(String(param1["sv"]).toLowerCase() == "true")
            {
               _loc2_.isUseStageVideo = true;
            }
         }
         _loc2_.lang = "";
         if(param1["lang"])
         {
            _loc2_.lang = param1["lang"];
         }
         if(!(param1["skincolor1"] == null) && !(param1["skincolor1"] == ""))
         {
            _loc2_.skincolor1 = param1["skincolor1"];
         }
         if(!(param1["skincolor2"] == null) && !(param1["skincolor2"] == ""))
         {
            _loc2_.skincolor2 = param1["skincolor2"];
         }
         if(!(param1["skinalpha"] == null) && !(param1["skinalpha"] == ""))
         {
            _loc2_.skinalpha = parseFloat(param1["skinalpha"]);
         }
         if(param1["wd"])
         {
            _loc2_.wd = param1["wd"];
         }
         if(param1["imglogo"])
         {
            if(StringUtil.isDomianLegal(param1["imglogo"]))
            {
               _loc2_.imglogo = param1["imglogo"];
            }
         }
         _loc2_.policy = param1["policy"] == null?false:param1["policy"];
         _loc2_.allowP2P = param1["allowp2p"] == null?false:param1["allowp2p"];
         _loc2_.ykstreamURL = param1["ykstreamurl"] == null?null:param1["ykstreamurl"];
         if(param1["pvid"])
         {
            _loc2_.pvid = param1["pvid"];
         }
         if(param1["frame"])
         {
            _loc2_.frame = param1["frame"];
         }
         if(param1["unCookie"])
         {
            _loc2_.unCookie = param1["unCookie"];
         }
         if(param1["playURL"])
         {
            _loc2_.playURL = param1["playURL"];
         }
         if(param1["vext"])
         {
            _loc2_.vext = param1["vext"];
         }
         if(param1["plchid"])
         {
            _loc2_.plchid = param1["plchid"];
         }
         if(param1["pb"])
         {
            _loc2_.pb = param1["pb"];
         }
         if(param1["ev"])
         {
            _loc2_.ev = param1["ev"];
         }
         if(param1.hasOwnProperty("om"))
         {
            if(String(param1["om"]).toLowerCase() == "true")
            {
               _loc2_.om = true;
            }
         }
         if(param1.hasOwnProperty("tdinfo"))
         {
            _loc2_.tdinfo = param1.tdinfo;
         }
         if(param1.hasOwnProperty("tdstart"))
         {
            _loc2_.tdstart = param1.tdstart;
         }
         if(param1.hasOwnProperty("tdadcontrol"))
         {
            if(String(param1["tdadcontrol"]).toLowerCase() == "true")
            {
               _loc2_.tdadcontrol = true;
            }
         }
         _loc2_.uepflag = false;
         if(param1["uepflag"] != null)
         {
            if(param1["uepflag"] == "1")
            {
               _loc2_.uepflag = true;
            }
         }
         _loc2_.ikuport = 0;
         if(param1["ikuport"] != null)
         {
            _loc2_.ikuport = param1["ikuport"];
         }
         _loc2_.yktk = null;
         if(param1["yktk"] != null)
         {
            _loc2_.yktk = param1["yktk"];
         }
         if(param1.hasOwnProperty("styleid"))
         {
            _loc2_.styleid = param1["styleid"];
         }
         return _loc2_;
      }
   }
}
